home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Brailler 0.5ß / Brailler 0.5ß.source / brlr ƒ / brlr conversion.c next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.8 KB  |  136 lines  |  [TEXT/MMCC]

  1. #include "brlr conversion.h"
  2. #include "brlr main window.h"
  3.  
  4. unsigned char DealWithLetter(unsigned char theChar, short *time)
  5. {
  6.     if ((*time)==1)
  7.     {
  8.         if ((theChar>='0') && (theChar<='9'))
  9.         {
  10.             (*time)++;
  11.             return Dots("\p3456");
  12.         }
  13.         if ((theChar=='[') || (theChar=='{') || (theChar=='<') || ((theChar>='A') && (theChar<='Z')))
  14.         {
  15.             (*time)++;
  16.             return Dots("\p6");
  17.         }
  18.         if ((theChar==']') || (theChar=='}') || (theChar=='>'))
  19.         {
  20.             (*time)++;
  21.             return Dots("\p356");
  22.         }
  23.         if ((theChar=='*') || (theChar=='…') || (theChar=='–') || (theChar=='—'))
  24.             (*time)++;
  25.     }
  26.     
  27.     if ((*time)==2)
  28.     {
  29.         if ((theChar=='…') || (theChar=='—'))
  30.             (*time)++;
  31.     }
  32.     
  33.     if ((*time)==3)
  34.     {
  35.         if (theChar=='—')
  36.             (*time)++;
  37.     }
  38.     
  39.     if ((theChar>='A') && (theChar<='Z'))
  40.         theChar|=0x20;
  41.  
  42.     switch (theChar)
  43.     {
  44.         case '1':
  45.         case 'a':    return Dots("\p1");
  46.         case '2':
  47.         case 'b':    return Dots("\p12");
  48.         case '3':
  49.         case 'c':    return Dots("\p14");
  50.         case '4':
  51.         case 'd':    return Dots("\p145");
  52.         case '5':
  53.         case 'e':    return Dots("\p15");
  54.         case '6':
  55.         case 'f':    return Dots("\p124");
  56.         case '7':
  57.         case 'g':    return Dots("\p1245");
  58.         case '8':
  59.         case 'h':    return Dots("\p125");
  60.         case '9':
  61.         case 'i':    return Dots("\p24");
  62.         case '0':
  63.         case 'j':    return Dots("\p245");
  64.         case 'k':    return Dots("\p13");
  65.         case 'l':    return Dots("\p123");
  66.         case 'm':    return Dots("\p134");
  67.         case 'n':    return Dots("\p1345");
  68.         case 'o':    return Dots("\p135");
  69.         case 'p':    return Dots("\p1234");
  70.         case 'q':    return Dots("\p12345");
  71.         case 'r':    return Dots("\p1235");
  72.         case 's':    return Dots("\p234");
  73.         case 't':    return Dots("\p2345");
  74.         case 'u':    return Dots("\p136");
  75.         case 'v':    return Dots("\p1236");
  76.         case 'w':    return Dots("\p2456");
  77.         case 'x':    return Dots("\p1346");
  78.         case 'y':    return Dots("\p13456");
  79.         case 'z':    return Dots("\p1356");
  80.         case ',':    return Dots("\p2");
  81.         case ':':    return Dots("\p25");
  82.         case '-':    return Dots("\p36");
  83.         case ';':    return Dots("\p23");
  84.         case '.':    return Dots("\p256");
  85.         case '!':    return Dots("\p235");
  86.         case '(':
  87.         case ')':    return Dots("\p2356");
  88.         case '?':
  89.         case '"':
  90.         case '“':
  91.         case '[':
  92.         case '{':
  93.         case '<':    return Dots("\p236");
  94.         case '…':
  95.         case '\'':
  96.         case '”':
  97.         case ']':
  98.         case '}':
  99.         case '>':    return Dots("\p3");
  100.         case '*':    return Dots("\p35");
  101.         case '/':    return Dots("\p34");
  102.         case '–':
  103.         case '—':    return Dots("\p36");
  104.         case ' ':
  105.         case '\r':    return theChar;
  106.         case 0x03:    return '\r';
  107.     }
  108.     
  109.     return 0x00;
  110. }
  111.  
  112. unsigned char Dots(Str15 dotStr)
  113. {
  114.     unsigned char    result;
  115.     short            i;
  116.     
  117.     result=0x00;
  118.     if (dotStr[0]==0x00)
  119.         return result;
  120.     
  121.     for (i=1; i<=dotStr[0]; i++)
  122.     {
  123.         switch (dotStr[i])
  124.         {
  125.             case '1':    result|=0x01;    break;
  126.             case '2':    result|=0x02;    break;
  127.             case '3':    result|=0x04;    break;
  128.             case '4':    result|=0x08;    break;
  129.             case '5':    result|=0x10;    break;
  130.             case '6':    result|=0x20;    break;
  131.         }
  132.     }
  133.     
  134.     return result+' ';
  135. }
  136.